package com.briup.store.web.controller;

import com.briup.common.response.Result;
import com.briup.store.domain.dto.UserRegisterDTO;
import com.briup.store.domain.dto.UserUpdateDTO;
import com.briup.store.domain.dto.UserUpdatePasswordDTO;
import com.briup.store.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/users")
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 注册用户
     */
    @PostMapping
    public Result registerUser(@RequestBody UserRegisterDTO userRegister) {
        userService.register(userRegister);
        return Result.success();
    }


    /**
     * 修改当前用户信息
     */
    @PutMapping
    public Result updateUser(@RequestBody UserUpdateDTO userUpdate){
        userService.updateUser(userUpdate);
        return Result.success();
    }


    /**
     * 修改密码
     */
    @PutMapping("/updatePassword")
    public Result updatePassword(@RequestBody UserUpdatePasswordDTO userUpdatePassword){
        userService.updatePassword(userUpdatePassword);
        return Result.success();
    }

}
